package com.oig.sys.query;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 1、json转sql
 * 2、查询条件解析
 *
 * 查询参数格式：
 *
 * {
 * "page":[0,20],
 * "where":{"$and":[{"optime":{"$between":[1614528000000,1616256000000]}},
 *                  {"warehouseId":{"$in":[1,3,4]}},
 *                  {"itemName":{"$like":"牛肉%"}},
 *                  {"opType":{"$in":[1]}},
 *                  {"containerNo":{"$eq":"222"}}]},
 * "sort":{"warehouseId":"asc"}
 * }
 * where 和 sort 传都是别名
 */
@Schema(description = "通用查询请求参数")
@Data
public class SysCommQueryReq implements Serializable {

    @Schema(description = "分页参数格式[0,100]")
    private List<Integer> page = new ArrayList<Integer>(){{add(0);add(20);}};
    @Schema(description = "排序条件格式：{\"warehouseId\":\"asc\"}")
    private Map<String, String> sort = new HashMap<>();
    @Schema(description = "查询条件 mongo表达式json")
    private Object where ;

    @Parameter(hidden = true)
    @JsonIgnore
    private Object innerWhere; //ConditionExp对象用于后端查询条件插入，如权限过滤等, where 是or条件，插入and条件有问题

    @Schema(description = "过滤列,后面做列权限用--返回数据排除掉指定的列")
    private List<String> columnPropertyList;
}
